package com.wang.designpattern.memento.game;


public class Client {
    public static void main(String[] args) {
        GameRole gameRole = new GameRole("wang", 100, 50);
        System.out.println("和boss大战前的状态：");
        gameRole.display();

        GameRole gameRole1 = new GameRole("hui", 80, 90);
        gameRole1.display();

        Caretaker caretaker = new Caretaker();
        caretaker.setRoleMementoListMap(gameRole.createMemento(caretaker));
        caretaker.setRoleMementoListMap(gameRole1.createMemento(caretaker));

        System.out.println("和第一个boss大战");
        gameRole.setVit(90);
        gameRole.setDef(40);
        gameRole.display();

        gameRole1.setVit(70);
        gameRole1.setDef(50);
        gameRole1.display();
        // 保存和第一个boss大战后的状态
        caretaker.setRoleMementoListMap(gameRole.createMemento(caretaker));
        caretaker.setRoleMementoListMap(gameRole1.createMemento(caretaker));

        System.out.println("和第二个boss大战");
        gameRole.setVit(70);
        gameRole.setDef(30);
        gameRole.display();

        gameRole1.setVit(60);
        gameRole1.setDef(50);
        gameRole1.display();

        System.out.println("大战后恢复到第一个boss大战后的状态");
        gameRole.recoverGameRoleFromMemento(caretaker.getRoleMementoListMap(), 1);
        gameRole.display();

        gameRole1.recoverGameRoleFromMemento(caretaker.getRoleMementoListMap(), 1);
        gameRole1.display();
    }
}
